﻿#include "NedAllocatorImpl.h"
#include "tcmalloc.h"

void* allocBytes(size_t count)
{
    void* ptr = NULL;

    ptr = tc_malloc(count);

	return ptr;
}

void deallocBytes(void* ptr)
{
	if(!ptr)
		return;

    tc_free(ptr);
}

void* allocBytesAligned(size_t align, size_t count)
{
	const size_t SIMD_ALIGNMENT = 16;
    void* ptr =  NULL;

    ptr = align ? tc_memalign(align, count)
               : tc_memalign(SIMD_ALIGNMENT, count);

	return ptr;
}

void deallocBytesAligned(size_t align, void* ptr)
{
	if (!ptr)
		return;

    tc_free(ptr);
}

void* MemoryMalloc(size_t size)
{
    void* ptr = NULL;

    ptr = tc_malloc(size);

    return ptr;
 }

void MemoryFree( void* ptr )
{
    if(!ptr)
        return;

    tc_free(ptr);
}

void *Memorycalloc( size_t num,size_t size )
{
    void* ptr = NULL;

    ptr = tc_calloc(num,size);

    return ptr;
}

void *Memoryrealloc( void* memblock, size_t size )
{
    if(!memblock)
        return NULL;
    void* ptr = NULL;

    ptr = tc_realloc(memblock,size);

    return ptr;
}

void DestroyMemory()
{

}
